package com.scau.service.impl.business;

import java.io.Serializable;

import org.springframework.stereotype.Component;

import com.scau.exception.BusinessException;
import com.scau.model.business.Purchase;
import com.scau.service.BaseService;
@Component
public class PurchaseService extends BaseService<Purchase> implements Serializable{
	public void save(Purchase purchase) throws BusinessException{
		if (null != purchase && null != purchase.getPurchase_id()) {
			if(null != purchase.getId() && 0 != purchase.getId()){
				update(purchase);
			}else{
				add(purchase);
			}
		}else {
			throw new BusinessException("采购单ID不能为空!");
		}
	}
	@Override
	public Purchase get(Purchase entity){
		if(null!=entity&&null!=entity.getId()&&0!=entity.getId()){
			return super.get(entity, entity.getId());
		}else if (null!=entity) {
			return super.get(entity);
		}else {
			return null;
		}
	}
}
